package test.list;

import test.bean.Event;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Comparator;

public class EventTimeComparator implements Comparator<Event> {
    private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");

    @Override
    public int compare(Event e1, Event e2) {
        LocalDateTime time1 = LocalDateTime.parse(e1.getEventTime(), formatter);
        LocalDateTime time2 = LocalDateTime.parse(e2.getEventTime(), formatter);
        return time1.compareTo(time2);
    }
}
